<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Upload extends MY_Controller {
    function __construct()
    {
        parent::__construct();
        $this->check_manage_session();//判断用户是否登录
    }
    
    public function index()
    {
        //$this->load->view('admin/upload_form', array('error' => ' ' ));
    }
    
    public function do_upload()
    {
        if ( ! $this->upload->do_upload('file'))
        {
            $data['error']=$this->upload->display_errors('','');
            //$data = array('error' => $this->upload->display_errors());
            //$this->load->view('admin/upload_form', $error);
        }
        else
        {
            //$data['success']=$this->upload->data();
            $data['success']=$this->upload->data('file_name');
            //$data = array('upload_data' => $this->upload->data());
            //$this->load->view('admin/upload_success', $data);
        }

        echo json_encode($data);
    }
}
